package org.brownflat.fxdate.data;

import org.brownflat.dbinit.upgrade.Upgrade;
import org.springframework.stereotype.Component;

/**
 * <p>&copy Rupert Jones 2011,2012</p>
 *
 * @author rup
 */
@Component
public class Upgrade0005CreateDefaultUserRole implements Upgrade {

    private static final int VERSION = 5;

    @Override
    public int getSequence() {
        return VERSION;
    }

    @Override
    public String getSql() {
        StringBuffer sql = new StringBuffer();
        sql.append("INSERT INTO FXDATE_ROLE (ID, NAME, CREATED_AT, UPDATED_AT) VALUES (1, 'ADMIN', sysdate, sysdate); COMMIT;");
        sql.append("INSERT INTO FXDATE_USER (ID, USERNAME, PASSWORD, FULL_NAME, CREATED_AT, UPDATED_AT) VALUES (1, 'admin', '5f4dcc3b5aa765d61d8327deb882cf99', 'Administrator', sysdate, sysdate); COMMIT;");
        sql.append("INSERT INTO FXDATE_USER_ROLE (ID, USER_ID, ROLE_ID, CREATED_AT, UPDATED_AT) VALUES (1, 1, 1, sysdate, sysdate); COMMIT;");
        return sql.toString();
    }

    @Override
    public String getName() {
        return "Create default user and role data";
    }
}
